//排序加双指针N2logN
let nums = [24,3,82,22,35,84,19]
var triangleNumber = function(nums) {
    nums.sort((a,b)=>a-b)
    let ans = 0
    let n = nums.length-1
    for(let i=n;i>1;i--){
        let left = 0
        let right = i-1
        while(right>left){
            if((nums[right]+nums[left])>nums[i]){
                ans = ans +right-left
                right--
            }else{
                left++
            }
        }
    }
    return ans
}
console.log(triangleNumber(nums));
